package com.echo.code.spring.springbootdemo.schedule;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * Description
 *
 * @author baiyp
 * @version 1.0.0
 * @date 2019/04/28
 */
@Component
@Slf4j
public class ScheduledTaskService {

  @Scheduled(fixedRate = 5000)
  public void print() {
    try {
      TimeUnit.SECONDS.sleep(1);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    log.info("{}: {}", Thread.currentThread().getName(), "print");
  }
}
